package com.btr.ivle.helper;

import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteDatabase.CursorFactory;
import android.database.sqlite.SQLiteOpenHelper;

public class DatabaseModuleItem extends SQLiteOpenHelper {

	private String tableName=null;
	public final String colID="itemID";
	public final String colName="itemName";
	public final String colCode="itemCourseCode";
	public final String colType="itemType";
	public final String colBadgeTool="itemBadgeTool";
	
	public DatabaseModuleItem(Context context, String name, CursorFactory factory, int version) {
		super(context, name, factory, version);
		this.tableName = name;
	}
	
	public void onCreate(SQLiteDatabase db) {
		  db.execSQL("CREATE TABLE IF NOT EXISTS "+ tableName +" ( "+ colID + " TEXT, "+
				  colName + " TEXT, " + colCode + " TEXT, " + colType + " TEXT, " + colBadgeTool
				  +" INTEGER, PRIMARY KEY (" + colID + ", " + colType + "))"
				  );
	}
	
	public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
		  db.execSQL("DROP TABLE IF EXISTS "+ tableName);
		  onCreate(db);
	 }
}
